package de.hpi.generator.config;

public class ColumnModel {

    /**
     * @uml.property  name="name"
     */
    public String name;
    /**
     * @uml.property  name="cellSize"
     */
    public int cellSize;
    /**
     * @uml.property  name="dataType"
     */
    public String dataType = null;
    public String unique = null;
    public String key = null;
    public String key_group = null;
    public String foreignkey = null;
    /**
     * contains info about Distribution Model and its params
     */
    public DistributionModel distribution = null;

    /**
     * Constructor using for row generator
     */
    public ColumnModel(String aName, int aCellSize, String aDataType, DistributionModel distribution, String aUnique, String aKey,
            String aKeyGroup, String aForeignkey) {

        InitFields(aName, aCellSize, aDataType, distribution);

        this.unique = aUnique;
        this.key = aKey;
        this.key_group = aKeyGroup;
        this.foreignkey = aForeignkey;

    }

    private void InitFields(String aName, int aCellSize, String aDataType, DistributionModel distribution) {
        this.name = aName;
        this.cellSize = aCellSize;
        this.dataType = aDataType;
        this.distribution = distribution;
    }

    public ColumnModel(String aName, int aCellSize, String aDataType,
            DistributionModel distribution) {

        InitFields(aName, aCellSize, aDataType, null);
        this.distribution = distribution;
    }
    transient boolean isPartOfFunctionalDependency = false;

    public boolean isPartOfFunctionalDependency() {
        return isPartOfFunctionalDependency;
    }

    public void setPartOfFunctionalDependency(boolean isPartOfFunctionalDependency) {
        this.isPartOfFunctionalDependency = isPartOfFunctionalDependency;
    }

    @Override
    public String toString() {
        return String.format("{name: %s, datatype: %s, cellSize: %d, distribution: %s}\n",
                this.name, this.dataType, this.cellSize, this.distribution.toString());
    }
}
